﻿using System.Security.Principal;

namespace Web.Infrastructure.Security
{
    /// <summary>
    /// Implements <see cref="IIdentity"/> in a web-specific way.
    /// </summary>
    public class WebIdentity : IIdentity
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="WebIdentity"/> class.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="isAuthenticated">if set to <c>true</c> user is authenticated.</param>
        public WebIdentity(string userName, bool isAuthenticated)
        {


            Name = userName;
            IsAuthenticated = isAuthenticated;
        }

        /// <summary>
        /// Gets the name of the current user.
        /// </summary>
        /// <returns>The name of the user on whose behalf the code is running.</returns>
        public string Name { get; private set; }

        /// <summary>
        /// Gets the type of authentication used.
        /// </summary>
        /// <returns>The type of authentication used to identify the user.</returns>
        public string AuthenticationType
        {
            get { return "Basic"; }
        }

        /// <summary>
        /// Gets a value indicating whether the user has been authenticated.
        /// </summary>
        /// <returns>true if the user was authenticated; otherwise, false.</returns>
        public bool IsAuthenticated
        {
            get; internal set;
        }
    }
}